import {
  Controller,
  Get,
  Inject,
  Version,
  VERSION_NEUTRAL,
} from '@nestjs/common';
import { AppService } from './app.service';
import { BusinessException } from 'src/common/exceptions/business.exception.filter';
import { ConfigService } from '@nestjs/config';

@Controller({
  path: 'user',
})
export class AppController {
  @Inject(ConfigService)
  private readonly configService: ConfigService;
  constructor(private readonly appService: AppService) {}

  @Get('hello')
  @Version([VERSION_NEUTRAL, '1'])
  getHello(): string {
    // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
    console.log('--->', this.configService.get('TEST_VALUE').name);
    return this.appService.getHello();
  }

  @Get('hello')
  @Version('2')
  getHelloV2(): string {
    const a: any = {};

    try {
      // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
      console.log(a.b.c);
      // eslint-disable-next-line @typescript-eslint/no-unused-vars
    } catch (e) {
      BusinessException.throwForbidden();
    }
    return 'Hello World V2!';
  }
}
